<!DOCTYPE HTML>
<html>
<head>
    <title>LocalStorageTest</title>
    <script type="text/javascript">
        function record()
        {
            if(typeof(localStorage) === "undefined")
                alert("Browser does not support local storage.")
            else
            {
                try{
                    newDate = new Date();
                    localStorage.setItem("date",newDate);
                    name = document.getElementById("name").value;
                    localStorage.setItem("name",name);
                    //alert("访客：" + name);
                }
                catch(e)
                {
                    alert("Error:" + e.toString());
                }
            }
        }

        function display()
        {
            try{
                name = localStorage.getItem("name");
                date = localStorage.getItem("date");
                displaySpan = document.getElementById("displaySpan");
                //alert("显示：" + date + ":" + name);
                displaySpan.innerHTML = date + ":" + name;
            }
            catch(e)
            {
                alert("Error:" + e.toString());
            }

        }
    </script>
</head>
<body>
    <input type="text" id="name"/>
    <input type="button" id="record" value="记录" onclick="record()"/>
    <input type="button" id="display" value="显示" onclick="display()"/>
    <br/>
    <span id="displaySpan">en ?</span>
</body>
</html>